1
2
3
4 package joeq.Scheduler;
5
6 import joeq.Main.jq;
7
8 /***
9 * @author John Whaley <jwhaley@alum.mit.edu>
10 * @version $Id: ThreadUtils.java 1451 2004-03-09 06:27:08Z jwhaley $
11 */
12 public abstract class ThreadUtils {
13 public static jq_Thread getJQThread(java.lang.Thread t) {
14 return _delegate.getJQThread(t);
15 }
16 static interface Delegate {
17 jq_Thread getJQThread(java.lang.Thread t);
18 }
19
20 private static Delegate _delegate;
21 static {
22
23 _delegate = null;
24 boolean nullVM = jq.nullVM;
25 if (!nullVM) {
26 _delegate = attemptDelegate("joeq.Scheduler.FullThreadUtils");
27 }
28 if (_delegate == null) {
29 _delegate = new joeq.Scheduler.HostedThreadUtils();
30 }
31 }
32
33 private static Delegate attemptDelegate(String s) {
34 String type = "thread util delegate";
35 try {
36 Class c = Class.forName(s);
37 return (Delegate)c.newInstance();
38 } catch (java.lang.ClassNotFoundException x) {
39 System.err.println("Cannot find "+type+" "+s+": "+x);
40 } catch (java.lang.InstantiationException x) {
41 System.err.println("Cannot instantiate "+type+" "+s+": "+x);
42 } catch (java.lang.IllegalAccessException x) {
43 System.err.println("Cannot access "+type+" "+s+": "+x);
44 }
45 return null;
46 }
47
48 }